package org.example.Lambda;

import java.util.function.IntPredicate;

/** @ClassName: LambdaDemo03 @Author NeySun @Description: TODO @Version 1.0 @Date 2022-03-03 */
public class LambdaDemo03 {

  public static void main(String[] args) {

    /** 1. */
    printNum(
        new IntPredicate() {
          @Override
          public boolean test(int value) {
            return value % 2 == 0;
          }
        });
    /** 2 */
    printNum(
        (int value) -> {
          return value % 2 == 0;
        });
  }

  public static void printNum(IntPredicate predicate) {
    int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    for (int i : arr) {
      if (predicate.test(i)) {
        System.out.println(i);
      }
    }
  }
}
